package com.zbkj.front.controller.v2.fund;

import com.zbkj.dal.base.page.CommonPage;
import com.zbkj.dal.base.result.CommonResult;
import com.zbkj.dal.pojo.request.PageParamRequest;
import com.zbkj.front.model.vo.LastRecordMonthVO;
import com.zbkj.front.service.fund.FrontFundV2Service;
import com.zbkj.service.model.front.req.fund.CrabRoeFundFlowReq;
import com.zbkj.service.model.front.req.fund.WithdrawApplyReq;
import com.zbkj.service.model.front.vo.fund.CrabRoeAccountVO;
import com.zbkj.service.model.front.vo.fund.MonthCrabRoeVO;
import com.zbkj.service.model.front.vo.fund.WithdrawDetailVO;
import com.zbkj.service.model.front.vo.user.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.util.List;

@Api("用户资金v2")
@Slf4j
@RestController
@RequestMapping("/api/front/v2/fund")
public class FundController {

    @Resource
    private FrontFundV2Service frontFundV2Service;

    @ApiOperation(value = "用户资金账户信息", tags = {"我的"})
    @GetMapping("/account-info")
    public CommonResult<UserFundAccountVO> userFundAccount() {
        return CommonResult.success(frontFundV2Service.userFundAccount());
    }

    @ApiOperation(value = "雅识账户信息", tags = {"雅识账户"})
    @GetMapping("/crab-roe/account")
    public CommonResult<CrabRoeAccountVO> crabRoeAccount() {
        return CommonResult.success(frontFundV2Service.userCrabRoeAccount());
    }

    @ApiOperation(value = "雅识账户流水", tags = {"雅识账户"})
    @GetMapping("/current/crab-roe/flow")
    public CommonResult<List<CurrentFundFlowVO>> currentFundFlow() {
        return CommonResult.success(frontFundV2Service.currentFundFlow());
    }

    @ApiOperation(value = "雅识账户流水", tags = {"雅识账户"})
    @GetMapping("/crab-roe/flow")
    public CommonResult<CommonPage<FundFlowVO>> crabRoeFundFlow(CrabRoeFundFlowReq req) {
        return CommonResult.success(frontFundV2Service.crabRoeFundFlow(req));
    }

    @ApiOperation(value = "雅识账户月度金额", tags = {"雅识账户"})
    @ApiImplicitParams(
            @ApiImplicitParam(name = "month", value = "查询月份", required = true, example = "2024-01")
    )
    @GetMapping("/crab-roe/month")
    public CommonResult<MonthCrabRoeVO> monthCrabRoe(@RequestParam("month") @NotBlank(message = "月份 不能为空") String month) {
        return CommonResult.success(frontFundV2Service.monthCrabRoeFlow(month));
    }

    @ApiOperation(value = "提现申请", tags = {"雅识账户"})
    @PostMapping("/crab-roe/withdraw/apply")
    public CommonResult<String> withdrawApply(@RequestBody @Validated WithdrawApplyReq req) {
        return CommonResult.success(frontFundV2Service.withdrawApply(req));
    }

    @ApiOperation(value = "提现详情", tags = {"雅识账户"})
    @GetMapping("/crab-roe/withdraw/detail")
    public CommonResult<WithdrawDetailVO> withdrawDetail(@RequestParam("withdrawNo") String withdrawNo) {
        return CommonResult.success(frontFundV2Service.withdrawDetail(withdrawNo));
    }

    @ApiOperation(value = "用户额度信息", tags = {"会员权益", "承享额度"})
    @GetMapping("/quota/info")
    public CommonResult<UserQuotaInfoVO> userQuotaInfo() {
        return CommonResult.success(frontFundV2Service.userUserQuotaInfo());
    }

    @ApiOperation(value = "用户等级计算额度流水", tags = "承享额度")
    @GetMapping("/quota/total/fund/flow")
    public CommonResult<CommonPage<QuotaFundFlowVO>> totalQuotaFundFlow(PageParamRequest req) {
        return CommonResult.success(frontFundV2Service.totalQuotaFundFlow(req));
    }

    @ApiOperation(value = "用户可用额度流水", tags = "承享额度")
    @GetMapping("/quota/available/fund/flow")
    public CommonResult<CommonPage<QuotaFundFlowVO>> availableQuotaFundFlow(PageParamRequest req) {
        return CommonResult.success(frontFundV2Service.availableQuotaFundFlow(req));
    }

    @ApiOperation(value = "最近流水月份", tags = "雅识账户")
    @GetMapping("/last/record/month")
    public CommonResult<LastRecordMonthVO> lastRecordMonth() {
        return CommonResult.success(frontFundV2Service.lastRecordMonth());
    }

}
